<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="org.huqiwen.blog.data.BlogDataBean"%>
<%@page import="org.huqiwen.blog.data.CommentDataBean"%>
<% BlogDataBean blogBean = (BlogDataBean)request.getAttribute("bean");
	String username = (String)session.getAttribute("username");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><%=blogBean.getBlogTitle()%></title>
<link type="text/css" href="skin/default/css/index.css" rel="stylesheet" />
<link type="text/css" href="skin/default/css/blogDetail.css" rel="stylesheet"/>
<script type="text/javascript" src="js/verify.js"></script>
<jsp:useBean id="commBean" class="org.huqiwen.blog.logic.CommentLogicBean"></jsp:useBean>
<%
	String str_curPage = request.getParameter("curPage");
	if(str_curPage!=null){
		commBean.setCurPage(Integer.parseInt(str_curPage));
	}
	int allPage = commBean.getAllPage();	
	int allRows = commBean.getAllRows();
	int curPage = commBean.getCurPage();
	int pageSize = commBean.getPageSize();
	 
	List<CommentDataBean> comList = commBean.findAllComment(blogBean.getBlogId());
%>
</head>	
<body>
	<div id="container">
		<jsp:include page="head.jsp"/>
		<div id="blogmain">			
			 <!-- 文章标题 -->
			 <div class="tit"><%=blogBean.getBlogTitle()%></div>
			 <!-- 发表日期 -->
			 <div class="date" id="date"><%=blogBean.getPostData()%></div>
			 <!-- 文章正文 -->
			<div class="content"><%=blogBean.getBlogContent()%></div>
			<!-- 文章类别 -->
			<div class="blogcat">
				<ul>
				<li>分类：<a href="FindByCatServlet?cat=<%=blogBean.getBlogCategory()%>"><%=blogBean.getBlogCategory()%></a> |</li>
				<%if(username!=null){%>
				<li><a href="BlogActionServlet?method=editorBlog&id=<%=blogBean.getBlogId()%>">编辑</a> |</li>
				<li><a href="BlogActionServlet?method=delBlog&id=<%=blogBean.getBlogId()%>">删除</a> |</li>
				<%}%>
				<li>浏览(<%=blogBean.getBlogCount()%>)</li>
				</ul><br />
			</div>
			<hr />
			<div class="comm">
			<h5>网友评论：</h5>
			<hr />
			<% 
				//如果回复不为空，则显示评论，否则不显示
				if(comList.size()!=0){
					for(int i=0;i<comList.size();i++){
						CommentDataBean comBean = (CommentDataBean)comList.get(i);
			%>
				<span><%=i+1%> </span>
				<span><a href="<%=comBean.getCommentAuthorUrl()%>"><%=comBean.getCommentAuthor()%></a></span>
				<span> | <%=comBean.getCommentDate().substring(0,19)%></span>
				<%if(username!=null){%>
				<span> | <a href="CommentActionServlet?method=delComment&id=<%=comBean.getCommentId()%>&blogId=<%=blogBean.getBlogId()%>">删除</a></span>
				<%}%>
				<div><%=comBean.getCommentContent()%></div>
				<hr />
			<%}} %>		
			<!-- 分页 -->
			<span　class="paging">
			<%if(curPage!=1){%>
				<a href="BlogActionServlet?method=detailBlog&id=<%=blogBean.getBlogId()%>&curPage=1">首页</a>
				<a href="BlogActionServlet?method=detailBlog&id=<%=blogBean.getBlogId()%>&curPage=<%=curPage-1%>">上一页</a>
			<%}if(curPage!=commBean.getAllPage()){%>
				<a href="BlogActionServlet?method=detailBlog&id=<%=blogBean.getBlogId()%>&curPage=<%=curPage+1%>">下一页</a>
				<a href="BlogActionServlet?method=detailBlog&id=<%=blogBean.getBlogId()%>&curPage=<%=commBean.getAllPage()%>">末页</a>
			<%} %>
			</span>		
		</div>
		<div id="comment">
			发表评论：
			<form action="CommentActionServlet?method=addComment" name="comment" method="post">
			<!-- 文章编号 隐藏域 -->
			<input type="hidden" name="blogId" value="<%=blogBean.getBlogId()%>" />
			<table>			
				<tr>
					<td>姓名： </td>
					<td><input type="text" name="name" id="name"/><span>(必填)</span></td>
				</tr>
				<tr>
					<td>Email：</td>
					<td><input type="text" name="email" id="email"/><span>(选填)</span></td>
				</tr> 
				<tr>
					<td>主页：</td>
					<td><input type="text" name="mainpage"/><span>(选填)</span></td>
				</tr> 
				<tr>
					<td>内容：</td>
					<td><textarea cols="40" rows="6" name="content" id="content"></textarea></td>
				</tr>
				<tr>
					<td></td>
					<td><input type="button" class="combtn" value="发表评论" onclick="Comment()"/></td>
				</tr>
			</table>
			
			</form>
			
		</div>
		</div>
		<%@include file="foot.jsp" %>
	</div>
</body>
</html>

